package tron.common;

import lombok.Data;

@Data
public class ApiPageResult<T> {
    private Integer state;
    private String message;
    private Long page;
    private Long size;
    private Long total;
    private T data;

    public static <T> ApiPageResult<T> success(T t,Long page,Long size,Long total) {
        ApiPageResult<T> apiPageResult = new ApiPageResult<>();
        apiPageResult.state = 200;
        apiPageResult.message = "success";
        apiPageResult.data = t;
        apiPageResult.page = page;
        apiPageResult.size = size;
        apiPageResult.total = total;
        return apiPageResult;
    }

    public static <T> ApiPageResult<T> fail(String message) {
        ApiPageResult<T> apiPageResult = new ApiPageResult<>();
        apiPageResult.state = 500;
        apiPageResult.message = message;
        apiPageResult.data = null;
        return apiPageResult;
    }
}
